package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import java.util.List;

import org.zhadoop.stream.cql.DriverContext;
import org.zhadoop.stream.cql.exception.CQLException;
import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.hooks.SemanticAnalyzeHook;
import org.zhadoop.stream.cql.semanticanalyzer.SemanticAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;
import org.zhadoop.stream.cql.tasks.Task;

/**
 * from 解析内容
 * 
 * @author zwd
 *
 */
public class StreamBodyContext extends ParseContext {

	private StreamSourceContext streamSource;
	
	private String alias;
	
	private boolean isUnidirection = false;

	@Override
	public String toString() {
StringBuilder sb = new StringBuilder();
        
        sb.append(streamSource.toString());
        if (alias != null)
        {
            sb.append(" AS " + alias);
        }
        
        if (isUnidirection)
        {
            sb.append(" UNIDIRECTION");
        }
        
        return sb.toString();
	}
 
	
	
	public StreamSourceContext getStreamSource() {
		return streamSource;
	}

	public void setStreamSource(StreamSourceContext streamSource) {
		this.streamSource = streamSource;
	}
	
	public String getAlias() {
		return alias;
	}



	public void setAlias(String alias) {
		this.alias = alias;
	}



	public boolean isUnidirection() {
		return isUnidirection;
	}



	public void setUnidirection(boolean isUnidirection) {
		this.isUnidirection = isUnidirection;
	}



	@Override
	public Task createTask(DriverContext driverContext, List<SemanticAnalyzeHook> analyzeHooks) throws CQLException {
		return null;
	}

	@Override
	public SemanticAnalyzer createAnalyzer() throws SemanticAnalyzerException {
		return null;
	}



	@Override
	protected void walkChild(ParseContextWalker walker) {
		walkExpression(walker, streamSource);
	}

}
